# This is a lib module for UPS

do '../web-lib.pl';
&init_config();


##############################
# read_ups_list()
##############################
sub read_ups_list
{
my $file=read_file_lines($config{'driverlist'});

for(my $i=0; $i<@$file; $i++)
{
	next if($file->[$i] =~ /^#/);
	next if($file->[$i] =~ /^\s*$/);
	$file->[$i] =~ /\"(.*)\"\s+\"(.*)\"\s+\"(.*)\"\s+\"(.*)\"/;
	push @{$content{$1}},$2.' '.$3.'='.$4;

}

return \%content;

}


##############################
# get_ups_conf()
##############################
sub get_ups_conf
{
my $file=read_file_lines($config{'upsconf'});

for(my $i=0; $i<@$file; $i++)
{
	next if($file->[$i] =~ /^#/);
	next if($file->[$i] =~ /^\s*$/);
	next if($file->[$i] =~ /\[ups\]/);
	$file->[$i] =~ /\s*(\w+)\s*=\s*(.+)\s*/;
	$upsconf{$1} = $2;

}

return \%upsconf;

}